import React, { Component } from 'react'
import {HashRouter as Hash , BrowserRouter as History,Route,Switch,Redirect} from "react-router-dom"
// import LoginCom from './login'
import MainCom from './main'
import NotFound404 from './errorpage/404';
import BadGateaway503 from './errorpage/503';
import LazyLoad  from "../utils/lazyload"

export  class MainRouter extends Component {
    render() {
        return (
            <Hash
                basename=""
            >
                <Route component={MainLayout}></Route>
            </Hash>    
        )
    }
}
//页面的主视图
export class MainLayout extends Component{
    render(){
        return(
            <div className="layout">  
               <Switch>
                   <Route path="/" exact  render={()=><Redirect to="/login"/>}></Route>
                   <Route path="/login" component={LazyLoad(()=>import('./login/index.js'))}></Route>
                   {/* <Route path="/main" component={MainCom}></Route> */}
                   <Route path="/main" component={LazyLoad(()=>import("./main"))} />
                   <Route path="/404" component={NotFound404}/>
                    <Route path="/503" component={BadGateaway503} />
                   <Route render={()=><Redirect to="/main"/>}></Route>
               </Switch>
            </div>
        )
    }
}